package cool.webstudy.admin.constant.enums.rescode;

import lombok.extern.slf4j.Slf4j;

/**
 *
 * @author think
 * @date 2024/7/17 9:08
 * @description: 认证、鉴权相关响应状态码枚举
 */
@Slf4j
public enum AuthResCodeEnum implements BaseResCodeEnum {
    RC_NOT_FOUND_TOKEN("401","未发现token！"),
    RC_TOKEN_EXPIRED("401","令牌过期！"),
    RC_ILLEGAL_TOKEN("401","非法令牌！");
    private String code;
    private String msg;
    AuthResCodeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    @Override
    public String code() {
        return code;
    }

    @Override
    public String msg() {
        return msg;
    }
    /**
     * 根据code获取msg静态方法，每个响应状态码枚举类都应有这个方法
     */
    public static AuthResCodeEnum getMsgByCode(String code) {
        for (AuthResCodeEnum authResCodeEnum : AuthResCodeEnum.values()) {
            if (authResCodeEnum.code().equals(code)) {
                return authResCodeEnum;
            }
        }
        log.error("getMsgByCode error:无法获取枚举值");
        return null;
    }
}
